<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="../../../assets/docs.css" rel="stylesheet" type="text/css" media="screen" />
<title>MooTools 1.3 参考文档 - Core/Core</title>
</head>

<body>
  <div class="doc">
    <div class="methods">
      <h4 class="menu-item"><a href="#Core">Core</a></h4>
      <div class="menu-item"><a href="#Core:typeOf">typeOf</a></div>
      <div class="menu-item"><a href="#Core:instanceOf">instanceOf</a></div>
      <h4 class="menu-item"><a href="#Deprecated-Functions">废弃的函数</a></h4>
      <div class="menu-item"><a href="#Deprecated-Functions:chk">chk</a></div>
      <div class="menu-item"><a href="#Deprecated-Functions:clear">clear</a></div>
      <div class="menu-item"><a href="#Deprecated-Functions:defined">defined</a></div>
      <div class="menu-item"><a href="#Deprecated-Functions:arguments">arguments</a></div>
      <div class="menu-item"><a href="#Deprecated-Functions:empty">empty</a></div>
      <div class="menu-item"><a href="#Deprecated-Functions:lambda">lambda</a></div>
      <div class="menu-item"><a href="#Deprecated-Functions:extend">extend</a></div>
      <div class="menu-item"><a href="#Deprecated-Functions:merge">merge</a></div>
      <div class="menu-item"><a href="#Deprecated-Functions:each">each</a></div>
      <div class="menu-item"><a href="#Deprecated-Functions:pick">pick</a></div>
      <div class="menu-item"><a href="#Deprecated-Functions:random">random</a></div>
      <div class="menu-item"><a href="#Deprecated-Functions:splat">splat</a></div>
      <div class="menu-item"><a href="#Deprecated-Functions:time">time</a></div>
      <div class="menu-item"><a href="#Deprecated-Functions:try">try</a></div>
      <div class="menu-item"><a href="#Deprecated-Functions:type">type</a></div>
    </div>
    <div class="l-border r-border span-15 content">
      <h1 id="Core"><a href="#Core">类型: Core</a></h1>
      <p class="description">Core 包含一系列在 <a target="_blank" href="http://mootools.net">MooTools</a> 中常用的工具函数. </p>
      <h2 id="Core:typeOf"><a href="#Core:typeOf">函数: typeOf</a></h2>
      <p class="description">检测传入参数的类型. </p>
      <h3>语法: </h3>
      <pre class="javascript"><span class="kw1">typeOf</span><span class="br0">(</span>obj<span class="br0">)</span>;</pre>
      <h3>参数: </h3>
      <ol>
        <li>obj - (<em>object</em>) 目标检测对象</li>
      </ol>
      <h3>返回值: </h3>
      <ul>
        <li>'element'    - (<em>string</em>) DOM元素节点</li>
        <li>'textnode'   - (<em>string</em>) DOM文本节点</li>
        <li>'whitespace' - (<em>string</em>) DOM空白节点</li>
        <li>'arguments'  - (<em>string</em>) arguments 对象</li>
        <li>'array'      - (<em>string</em>) 数组</li>
        <li>'object'     - (<em>string</em>) Object对象</li>
        <li>'string'     - (<em>string</em>) 字符串</li>
        <li>'number'     - (<em>string</em>) 数字</li>
        <li>'date'       - (<em>string</em>) 日期对象</li>
        <li>'boolean'    - (<em>string</em>) 布尔值</li>
        <li>'function'   - (<em>string</em>) 函数对象</li>
        <li>'regexp'     - (<em>string</em>) 正则表达式对象</li>
        <li>'class'      - (<em>string</em>) Class (由new Class创建, 或由其他Class对象扩展而来)</li>
        <li>'collection' - (<em>string</em>) 原生htmlelements集合, 如由方法childNodes, getElementsByTagName等获取到的结果</li>
        <li>'window'     - (<em>string</em>) window 对象</li>
        <li>'document'   - (<em>string</em>) document 对象</li>
        <li>'event'      - (<em>string</em>) 事件(event)对象</li>
        <li>false        - (<em>boolean</em>) undefined, null, NaN 或以上列出的类型都不是</li>
      </ul>
      <h3>示例: </h3>
      <pre class="javascript"><span class="kw2">var</span> myString = <span class="st0">'hello'</span>;
<span class="kw1">typeOf</span><span class="br0">(</span>myString<span class="br0">)</span>; <span class="co1">// 返回 "string".</span></pre>
      <h3>提示: </h3>
      <p>这个方法等同于 MooTools 1.2 里的 <em>$type</em> . </p>
      <h2 id="Core:instanceOf"><a href="#Core:instanceOf">函数: instanceOf</a></h2>
      <p class="description">检查一个对象是否是一个特定类型的实例. </p>
      <h3>语法: </h3>
      <pre class="javascript"><span class="kw1">instanceOf</span><span class="br0">(</span><span class="kw1">item</span>, object<span class="br0">)</span></pre>
      <h3>参数: </h3>
      <ol>
        <li>item - (<em>mixed</em>) 要检查的对象</li>
        <li>object - (<em>mixed</em>) 要比较的类型</li>
      </ol>
      <h3>返回值: </h3>
      <ul>
        <li>(<em>boolean</em>) 对象是否是这个类型的实例</li>
      </ul>
      <h3>示例: </h3>
      <pre class="javascript"><span class="kw2">var</span> foo = <span class="br0">[</span><span class="br0">]</span>;
<span class="kw1">instanceOf</span><span class="br0">(</span>foo, Array<span class="br0">)</span>  <span class="co1">// 返回 true</span>
<span class="kw1">instanceOf</span><span class="br0">(</span>foo, String<span class="br0">)</span> <span class="co1">// 返回 false</span>
&nbsp;
<span class="kw2">var</span> myClass = <span class="kw2">new</span> <span class="kw2">Class</span><span class="br0">(</span><span class="br0">)</span>;
<span class="kw2">var</span> bar = <span class="kw2">new</span> myClass<span class="br0">(</span><span class="br0">)</span>;

<span class="kw1">instanceOf</span><span class="br0">(</span>bar, myClass<span class="br0">)</span>    <span class="co1">// 返回 true</span>
</pre>
      <h1 id="Deprecated-Functions"><a href="#Deprecated-Functions">废弃的函数</a></h1>
      <h2 id="Deprecated-Functions:chk" class="description"><a href="#Deprecated-Functions:chk">函数: $chk</a></h2>
      <p class="description">这个方法已经被废弃, 并且 MooTools 2.0 中不会有替代的方法. </p>
      <p>如果你需要这个函数, 你可以这样实现它:</p>
      <h3>示例: </h3>
      <pre class="javascript"><span class="kw2">var</span> $chk = <span class="kw2">function</span><span class="br0">(</span>obj<span class="br0">)</span><span class="br0">{</span>
    <span class="kw1">return</span> !!<span class="br0">(</span>obj || obj === <span class="nu0">0</span><span class="br0">)</span>;
<span class="br0">}</span>;
</pre>
      <h2 id="Deprecated-Functions:clear"><a href="#Deprecated-Functions:clear">函数: $clear</a></h2>
      <p class="description">这个方法已经被废弃了. 请使用 <em>clearInterval</em> 和 <em>clearTimeout</em> 来代替. </p>
      <h3>另参考: </h3>
      <ul>
        <li> <a href="https://developer.mozilla.org/en/DOM/window.clearTimeout">MDC clearTimeout</a>, <a href="https://developer.mozilla.org/en/DOM/window.clearInterval">MDC clearInterval</a> </li>
      </ul>
      <h2 id="Deprecated-Functions:defined"><a href="#Deprecated-Functions:defined">函数: $defined</a></h2>
      <p class="description">这个方法已经被废弃了. </p>
      <p>如果你需要这个函数, 你可以这样实现它: </p>
      <h3>示例: </h3>
      <pre class="javascript"><span class="kw2">var</span> $defined = <span class="kw2">function</span><span class="br0">(</span>obj<span class="br0">)</span><span class="br0">{</span>
    <span class="kw1">return</span> <span class="br0">(</span>obj != undefined<span class="br0">)</span>;
<span class="br0">}</span>;
&nbsp;
<span class="co1">// 或者像这样来使用它</span>
<span class="kw1">if</span><span class="br0">(</span>obj != undefined<span class="br0">)</span><span class="br0">{</span>
    <span class="co1">// do something</span>
<span class="br0">}</span>
</pre>
      <h2 id="Deprecated-Functions:arguments"><a href="#Deprecated-Functions:arguments">函数: $arguments</a></h2>
      <p class="description">这个方法已经被废弃, 并且 MooTools 2.0 中不会有替代的方法. </p>
      <p>如果你需要这个函数, 你可以这样实现它:</p>
      <h3>示例: </h3>
      <pre class="javascript"><span class="kw2">var</span> $arguments = <span class="kw2">function</span><span class="br0">(</span>i<span class="br0">)</span><span class="br0">{</span>
    <span class="kw1">return</span> <span class="kw2">function</span><span class="br0">(</span><span class="br0">)</span><span class="br0">{</span>
        <span class="kw1">return</span> arguments<span class="br0">[</span>i<span class="br0">]</span>;
    <span class="br0">}</span>;
<span class="br0">}</span>;
</pre>
      <h2 id="Deprecated-Functions:empty"><a href="#Deprecated-Functions:empty">函数: $empty</a></h2>
      <p class="description">这个方法已经被废弃了.  使用 <a href="../../../docs/core/Types/Function.html#Function:Function-from">Function.from</a> 来代替. </p>
      <h3>示例: </h3>
      <pre class="javascript"><span class="kw2">var</span> myFunc = <span class="kw2">Function</span>.<span class="me1">from</span><span class="br0">(</span><span class="br0">)</span>;

<span class="co1">// 或者更好的实现方式:</span>
<span class="kw2">var</span> myFunc = <span class="kw2">function</span><span class="br0">(</span><span class="br0">)</span><span class="br0">{</span><span class="br0">}</span>;
</pre>
      <h2 id="Deprecated-Functions:lambda"><a href="#Deprecated-Functions:lambda">函数: $lambda</a></h2>
      <p class="description">这个方法已经被废弃了.  使用 <a href="../../../docs/core/Types/Function.html#Function:Function-from">Function.from</a> 来代替. </p>
      <h3>示例: </h3>
      <pre class="javascript">myLink.<span class="me1">addEvent</span><span class="br0">(</span><span class="st0">'click'</span>, <span class="kw2">Function</span>.<span class="me1">from</span><span class="br0">(</span><span class="kw2">false</span><span class="br0">)</span><span class="br0">)</span>; <span class="co1">// 阻止一个链接元素的点击事件</span>
</pre>
      <h2 id="Deprecated-Functions:extend"><a href="#Deprecated-Functions:extend">函数: $extend</a></h2>
      <p class="description">这个方法已经被废弃了.  请使用 <a href="../../../docs/core/Types/Object.html#Object:Object-append">Object.append</a> 来代替. </p>
      <h2 id="Deprecated-Functions:merge"><a href="#Deprecated-Functions:merge">函数: $merge</a></h2>
      <p class="description">这个方法已经被废弃了.  请使用 <a href="../../../docs/core/Types/Object.html#Object:Object-merge">Object.merge</a> 来代替. </p>
      <h2 id="Deprecated-Functions:each"><a href="#Deprecated-Functions:each">函数: $each</a></h2>
      <p class="description">这个方法已经被废弃了.  请使用 <a href="../../../docs/core/Types/Array.html#Array:Array-each">Array.each</a> or <a href="../../../docs/core/Types/Object.html#Object:Object-each">Object.each</a> 来代替. </p>
      <h2 id="Deprecated-Functions:pick"><a href="#Deprecated-Functions:pick">函数: $pick</a></h2>
      <p class="description">这个方法已经被废弃了.  请使用 <a href="../../../docs/core/Types/Array.html#Array:pick">Array.pick</a> 来代替. </p>
      <h2 id="Deprecated-Functions:random"><a href="#Deprecated-Functions:random">函数: $random</a></h2>
      <p class="description">这个方法已经被废弃了.  请使用 <a href="../../../docs/core/Types/Number.html#Number:Number-random">Number.random</a> 来代替. </p>
      <h2 id="Deprecated-Functions:splat"><a href="#Deprecated-Functions:splat">函数: $splat</a></h2>
      <p class="description">这个方法已经被废弃了.  请使用 <a href="../../../docs/core/Types/Array.html#Array:Array-from">Array.from</a> 来代替. </p>
      <h2 id="Deprecated-Functions:time"><a href="#Deprecated-Functions:time">函数: $time</a></h2>
      <p class="description">这个方法已经被废弃了.  请使用 <em>Date.now()</em> 来代替. </p>
      <h3>语法: </h3>
      <pre class="javascript"><span class="kw2">var</span> time = Date.<span class="me1">now</span><span class="br0">(</span><span class="br0">)</span>;
</pre>
      <h3>返回值: </h3>
      <ul>
        <li>(<em>number</em>) - 当前时间戳. </li>
      </ul>
      <h2 id="Deprecated-Functions:try"><a href="#Deprecated-Functions:try">函数: $try</a></h2>
      <p class="description">这个方法已经被废弃了.  请使用 <a href="../../../docs/core/Types/Function.html#Function:Function-attempt">Function.attempt</a> 来代替. </p>
      <h2 id="Deprecated-Functions:type"><a href="#Deprecated-Functions:type">函数: $type</a></h2>
      <p class="description">这个方法已经被废弃了.  请使用 <a href="#Core:typeOf">typeOf</a> 来代替. </p>
    </div>
  </div>
<script type="text/javascript" src="../../../assets/mootools-core-1.3.js"></script>
<script type="text/javascript" src="../../../assets/mootools-more-smoothscroll.js"></script>
<script type="text/javascript" src="../../../assets/doc-assist.js"></script>
</body>
</html>
